﻿//IT eBooks API Info Library. Simple .Net library to access the IT eBooks API Info http://it-ebooks-api.info/
//Copyright (C) 2014 Italo Pessoa <italo.pessoa@hotmail.com>

//This file is part of the program IT eBooks API Info Library.

//IT eBooks API Info Library is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITeBooks.API.Library.Model
{
    /// <summary>
    /// Class to represent a eBook
    /// </summary>
    public class EBook
    {
        #region Private Members

        private long _id;
        private string _title;
        private string _subTitle;
        private string _description;
        private string[] _authors;
        private long _isbn;
        private int _page;
        private int _year;
        private string _publisher;
        private string _imageLink;
        private System.Drawing.Image _image;
        private string _download;

        #endregion

        #region Constructors

        /// <summary>
        /// Initialize a book to view
        /// </summary>
        /// <param name="id">eBook ID</param>
        /// <param name="title">eBook title</param>
        /// <param name="subTitle">eBook Subtitle</param>
        /// <param name="description">eBook description</param>
        /// <param name="image">eBook image url</param>
        /// <param name="isbn">ISBN</param>
        public EBook(long id, string title, string subTitle, string description, string image, long isbn)
        {
            this._id = id;
            this._title = title;
            this._subTitle = subTitle;
            this._description = description;
            this._imageLink = image;
            this._isbn = isbn;
        }

        /// <summary>
        /// Initialize a book to view
        /// </summary>
        /// <param name="id">eBook ID</param>
        /// <param name="title">eBook title</param>
        /// <param name="subTitle">eBook Subtitle</param>
        /// <param name="description">eBook description</param>
        /// <param name="image">eBook image object</param>
        /// <param name="isbn">ISBN</param>
        public EBook(long id, string title, string subTitle, string description, System.Drawing.Image image, long isbn)
        {
            this._id = id;
            this._title = title;
            this._subTitle = subTitle;
            this._description = description;
            this._image = image;
            this._isbn = isbn;
        }

        /// <summary>
        /// Initialize a book with details
        /// </summary>
        /// <param name="id">eBook ID</param>
        /// <param name="title">eBook title</param>
        /// <param name="subTitle">eBook Subtitle</param>
        /// <param name="description">eBook description</param>
        /// <param name="image">eBook image object</param>
        /// <param name="isbn">ISBN</param>
        /// <param name="authors">Authors of the book</param>
        /// <param name="year">Year of publication</param>
        /// <param name="pages">Number of pages</param>
        /// <param name="publisher">Publisher's name</param>
        /// <param name="downloadLink">URL to download</param>
        public EBook(long id, string title, string subTitle, string description, System.Drawing.Image image, long isbn, string[] authors, int year, int pages, string publisher, string downloadLink)
        {
            this._id = id;
            this._title = title;
            this._subTitle = subTitle;
            this._description = description;
            this._image = image;
            this._isbn = isbn;

            this._authors = authors;
            this._year = year;
            this._page = pages;
            this._publisher = publisher;
            this._download = downloadLink;
        }

        /// <summary>
        /// Initialize a book with details
        /// </summary>
        /// <param name="id">eBook ID</param>
        /// <param name="title">eBook title</param>
        /// <param name="subTitle">eBook Subtitle</param>
        /// <param name="description">eBook description</param>
        /// <param name="image">eBook image url</param>
        /// <param name="isbn">ISBN</param>
        /// <param name="authors">Authors of the book</param>
        /// <param name="year">Year of publication</param>
        /// <param name="pages">Number of pages</param>
        /// <param name="publisher">Publisher's name</param>
        /// <param name="downloadLink">URL to download</param>
        public EBook(long id, string title, string subTitle, string description, string image, long isbn, string[] authors, int year, int pages, string publisher, string downloadLink)
        {
            this._id = id;
            this._title = title;
            this._subTitle = subTitle;
            this._description = description;
            this._imageLink = image;
            this._isbn = isbn;

            this._authors = authors;
            this._year = year;
            this._page = pages;
            this._publisher = publisher;
            this._download = downloadLink;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Book's ID
        /// </summary>
        public long ID
        {
            get { return this._id; }
        }

        /// <summary>
        /// Book's Title
        /// </summary>
        public string Title
        {
            get { return this._title; }
        }

        /// <summary>
        /// Book's Subtitle
        /// </summary>
        public string SubTitle
        {
            get { return this._subTitle; }
        }

        /// <summary>
        /// Book's description
        /// </summary>
        public string Description
        {
            get { return this._description; }
        }

        /// <summary>
        /// Book's image url
        /// </summary>
        public string ImageLink
        {
            get { return this._imageLink; }
        }

        /// <summary>
        /// Book's image object
        /// </summary>
        public System.Drawing.Image Image
        {
            get { return this._image; }
        }

        /// <summary>
        /// Book's ISBN code
        /// </summary>
        public long ISBN
        {
            get { return this._isbn; }
        }

        /// <summary>
        /// Number of pages
        /// </summary>
        public int Pages
        {
            get { return this._page; }
        }

        /// <summary>
        /// Year of publication
        /// </summary>
        public int Year
        {
            get { return this._year; }
        }

        /// <summary>
        /// Publisher
        /// </summary>
        public string Publisher
        {
            get { return this._publisher; }
        }

        /// <summary>
        /// Url to download
        /// </summary>
        public string Link
        {
            get { return this._download; }
        }

        /// <summary>
        /// Authors
        /// </summary>
        public string[] Authors
        {
            get { return this._authors; }
        }

        #endregion

        #region Equals/HashCode

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }
            else if (!(obj is EBook))
            {
                return false;
            }
            else
            {
                EBook ebook = obj as EBook;

                return this.ISBN == ebook.ISBN && this.ID == ebook.ID;
            }
        }

        public override int GetHashCode()
        {
            return this.ID.GetHashCode() * 16;
        }

        #endregion
    }
}
